package com.xh.core.convert;

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode;

import java.io.IOException;

/*
 * @Author daiwei
 * @Description
 * @Date 2019/3/21 16:29
 **/
public class JSONConverter extends JsonDeserializer<JSON> {
    @Override
    public JSON deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
        JsonNode node = jsonParser.getCodec().readTree(jsonParser);
        String jsonText=node.toString();
        JSON result=(JSON)JSON.parse(jsonText);
        return result;
    }
}
